<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>

<script>
    const formData = {
        name: "查小兵",
        year: 2022
    }
    //我的信息
    const info = {}
    Object.defineProperty(info, 'age', {
        //读age
        get() {
            return formData.year - 1998;
        },
        //写age
        set(val) {
            formData.year = 1998 + val;
        }
    })
</script>
</body>
</html>
